package com.hmy.cornpestdet.service;

import com.hmy.cornpestdet.mapper.AdminUploadInfoMapper;
import com.hmy.cornpestdet.utils.Result;
import com.hmy.cornpestdet.vo.UploadInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class AdminUploadInfoService {
    @Autowired
    private AdminUploadInfoMapper adminUploadInfoMapper;

    public Result getAllUploadInfo(){
        List<UploadInfoVo>uploadInfoVos = adminUploadInfoMapper.getAllUploadInfo();
        if(uploadInfoVos == null)return Result.Error("查询错误");
        return Result.Success("查询成功",uploadInfoVos);
    }

    public Result getCurrentPageUploadInfo(int currentPage, int pageSize){
        List<UploadInfoVo>uploadInfoVos = adminUploadInfoMapper.getCurrentPageUploadInfo(currentPage,pageSize);
        if(uploadInfoVos == null)return Result.Error("查询错误");
        return Result.Success("查询成功",uploadInfoVos);
    }

    public Result deleteUploadInfoByImageName( String imageName) {
        if(adminUploadInfoMapper.deleteUploadInfoByImageName(imageName) < 1){
            return Result.Error("删除失败");
        }
        return Result.Success("删除成功",getAllUploadInfo().getData());
    }


}
